const {exec} = require('../db/mysql')
const {genPassword} = require('../utils/crypto')
const login = async (username,password) => {
    username = escape(username)
    password = escape(password)
    //加密密码
    password = genPassword(password)
    // select username, realname from user where username = 'lisi%27%20--%20%27' and pwd = '456'
    const sql = `select username,realname from user where username='${username}' and pwd='${password}'`
    // console.log(sql);
    const rows = await exec(sql)
    return rows[0] || {}
}
module.exports = {
    login
}